package rabbit.dead;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import rabbit.util.RabbitMqUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Product
 * Package: rabbit.dead
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-10-26
 * Time: 21:38
 */

public class Product {

    //普通交换机
    public static final String NORMAL_EXCHANGE = "normal_exchange";

    //死信队列 生成者代码
    public static void main(String[] args) throws IOException, TimeoutException {

        //只需要发送消息给普通交换机即可
        Channel chanel = RabbitMqUtils.getChanel();
        //私信消息 要设置TTL的时间 存活消息
        AMQP.BasicProperties properties = new AMQP.BasicProperties().builder()
                .expiration("10000").build();

        for (int i = 0; i < 10; i++) {
            String message = "info" + i;
            //发送消息的参数 队列 routing 其他参数就是这是TTL时间的参数 消息体
            chanel.basicPublish(NORMAL_EXCHANGE,"zhangsan",properties,message.getBytes());
        }


    }
}